<%@ include file="../confHeader.jsp" %>
<%@ include file="../mensagens.jsp" %>
<html>
<head>
	
</head>
<body >

	
 <html:javascript formName="ProdutoForm" />  
 <html:form  action="produtoAction.do?method=gravar" method="POST" onsubmit="return validateProdutoForm(this);">
       <html:hidden property="idEspecProduto" />
   <div class='pageForm'>
      <div class='formTitle'>         		
	        <logic:equal value="true"  name="to"  property="update" >
	       		<bean:message key="app.form.update"/>
	       </logic:equal>
	       <logic:notEqual value="true"  name="to"  property="update">
		       	<bean:message key="app.form.create"/>
	       </logic:notEqual>
	       &nbsp;<bean:message key="produto.entity"/>

      </div>    
   
        <div class='formField'>
            <label><bean:message key="produto.nome"/></label>
            <html:text  property="nome" size="20" maxlength="255"  />
        </div>   
 
        <div class='formField'>
            <label><bean:message key="produto.descr"/></label>    <br>         
           	  <html:textarea    property="descricao" rows="7" cols="60"  onkeypress="javascript:limitLength(this,500)" 
               onkeyup="javascript:limitLength(this,500)" />	      
        </div>
        
        	${el:defineAllSearchResultsAsList('to.searcher', 'request', pageContext)}
       	<table><tr><td>
        <div class='formField'>
            <label><bean:message key="grupo.entity"/></label>            
             	<html:select  property="idGrupo"  onchange="javascript:listaSubGrupos()" >
					<html:option value=""></html:option>	
				
					<logic:present name="grupoList">
					<logic:iterate name="grupoList" id="grupo" >
						<html:option value="${grupo.idGrupo}" >${el:write('grupo.idGrupo',pageContext)}- ${el:write('grupo.nome',pageContext)}</html:option>
					</logic:iterate>					
					</logic:present>
				</html:select>
				
				
				
            
        </div>       
	     </td>
		  <td>
         <div class='formField' id='subgrupo'  >
            <label><bean:message key="subgrupo.entity"/></label>            
             	<html:select  property="idSubGrupo" >
					<html:option value=""></html:option>	
					<logic:present name="subgrupoList">					
					<logic:iterate name="subgrupoList" id="grupo" >
						<html:option value="${grupo.idGrupo}" >${el:write('grupo.idGrupo',pageContext)}- ${el:write('grupo.nome',pageContext)}</html:option>
					</logic:iterate>
					</logic:present>
				</html:select>
            
        </div></td></tr> </table>  
        
        <hr size="1">
           <div class='formButton'>  
             <a onclick="javascript:reset(ProdutoForm);" class="linkButton">  <bean:message key="app.button.reset"/></a>
      		 &nbsp;
		     <a onclick="javascript:gravar();" class="linkButton">  <bean:message key="app.button.store"/></a>
          </div>
            
    </div>
    </html:form>
   
      
<script type="text/javascript">
 // <!--
   
  var action= '<html:rewrite page="/produtoAction.do"/>';
  var nForm =  'ProdutoForm';

 function gravar(){	 
	 executeForm(nForm, action, 'gravar');
 }
 
 function listaSubGrupos(){
 	 showSubgrupo();
	 if(document.forms[nForm].idGrupo.selectedIndex != 0){
 		 executeForm(nForm, action, 'listaSubGrupos');
 	}else{
		 DHTMLUtil.hideElement('subgrupo'); 
		document.forms[nForm].idSubGrupo.selectedIndex  = 0;  	
 	 }
 }

 function showSubgrupo(){
	var show = false; 
	<logic:present name="subgrupoList" > show = true ;</logic:present>
	 if(show){
		 DHTMLUtil.showElement('subgrupo');    
	 }else{	 
		DHTMLUtil.hideElement('subgrupo'); 
		document.forms[nForm].idSubGrupo.selectedIndex  =0;  
	 }
 } 
 showSubgrupo();
  

  //-->
</script>
</body>
</html>
